package org.beetl.sql.spring;

import java.util.List;

import org.beetl.sql.core.SQLManager;
import org.beetl.sql.ext.spring.SpringBeetlSql;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class MyServiceImpl implements MyService {

	@Autowired
	SpringBeetlSql beetlsql ;
	
	@Override
	@Transactional
	public void saveUser(User user) {
		// TODO Auto-generated method stub
		
	}

	@Override
//	@Transactional(readOnly=true)
	public int total(User user) {
		
		SQLManager dao = beetlsql.getSQLMananger();
//		dao.getDs().onlyMasterBegin();
		List<User> list = dao.all(User.class);
		int total = list .size();
//		dao.getDs().onlyMasterEnd();
//		dao.deleteById(User.class, 3);
//		User u =new User();
//		u.id = 3;
//		u.name="hello";
//		u.age = 12;
//		dao.insert(User.class, u);
	
		System.out.println("t="+total);
//		if(1==1)throw new RuntimeException();
		return total;
//		
//		return dao.total(user);
	}

}
